<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui/css/H-ui.min.css"/>
    <%--引起冲突的样式--%>
    <%--<link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/table.css"/>--%>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/bootstrap.css"/>
    <!--_footer 作为公共模版分离出去-->
    <script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
    <!--/_footer /作为公共模版分离出去-->
    <title>报告细线结果 - </title>
</head>
<body>

<%--<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>--%>
<!--/_menu 作为公共模版分离出去-->
<section class="Hui-article-box" style="margin: 100px 30px">
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="cl pd-5 bg-1 bk-gray mt-20">
                <div class="mt-20">
                    <h3 align="center">体检报告检测表</h3>
                    <c:if test="${resultType eq '图片输出'}">
                        <form action="${pageContext.request.contextPath}/report/upload.action" method="post" enctype="multipart/form-data">
                            <label>上传体检图片：</label><input type="file" name="file"><br>
                                          <input type="text" name="name" value="${reportItemId}" hidden>
                            <input type="submit">
                        </form>
                    </c:if>

                    <c:if test="${resultType != '图片输出'}">
                    <table class="table table-border table-bordered table-hover table-bg table-sort">
                        <thead>
                        <tr class="text-c">
                            <th width="100">报告项目ID</th>
                            <th width="30">细项ID</th>
                            <th width="90">细项名</th>
                            <th width="30">细项单位</th>
                            <th width="30">细项结果</th>
                        </tr>
                        </thead>
                        <tbody>
                        <form id="asdf">
                            <c:if test="${not empty page}">
                                <c:forEach items="${page.list}" var="detail">
                                    <tr class="text-c">
                                        <td>${reportItemId}</td>
                                        <td>${detail.detailId}</td>
                                        <td>${detail.detailName}</td>
                                        <td>${detail.unit}</td>
                                        <input hidden type="text" name="detailsId" value="${detail.detailId}">
                                        <c:if test="${resultType=='手动输出'}">
                                            <td><input type="text" name="resultDetail"></td>
                                        </c:if>
                                        <c:if test="${resultType eq '机械输出'}">
                                            <td hidden><input type="text" value="${detail.min}" name="resultDetail">
                                            </td>
                                            <td>${detail.min}</td>
                                        </c:if>
                                    </tr>
                                </c:forEach>
                            </c:if>
                        </form>

                        </tbody>
                    </table>
                    <div id="page" style="float: right" align="center">
                        总共${page.pages}页，当前第${page.pageNum}页,每页总共${page.pageSize}。
                        <a id="firstPage" class="btn-sm btn-primary" onclick="changeNum(${page.prePage})">上一页</a>
                        <a id="lastPage" class="btn-sm btn-primary" onclick="changeNum(${page.nextPage})">下一页</a>
                    </div>

                </div>
            </div>
        </article>
        <div align="center">
            <input type="button" value="确认提交" onclick="sumbitResult()">
            <input type="button" value="返回" onclick="returnResult()">
        </div>
        </c:if>
    </div>
</section>

<script type="text/javascript">

    function sumbitResult() {
        var flag=true;
        var Result = document.getElementsByName("resultDetail");
        var Id = document.getElementsByName("detailsId");
        var detailResult = new Array();
        var detailsId = new Array();
        <%--var num=${sessionScope.num1};--%>
        for (i = 0; i < Result.length; i++) {
            detailResult[i] = Result[i].value;
            if(detailResult[i]==null||(detailResult[i]=='')){
                alert("体检结果不能为空");
                flag=false;
                return flag;

            }
        }
        for (i = 0; i < Id.length; i++) {
            detailsId[i] = Id[i].value;
        }
        if(flag){
            location.href = "${pageContext.request.contextPath}/report/reportSubmit.action?reportItemId=${reportItemId}&itemStateId=${itemStateId}&detailsId=" + detailsId + "&detailResult=" + detailResult;
        }

    }

    function returnResult() {
        location.href = "${pageContext.request.contextPath}/report/reportList.action"
    }

    $(function () {
        if (${page.isLastPage}) {
            $("#lastPage").removeAttr("onclick");
        }
    });

    function changeNum(obj) {
        var num = obj;
        window.location.href =
            "${pageContext.request.contextPath}/report/reportList.action?num=" + num;
    }


</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>